package com.lzw.mapper.admin;

import com.lzw.pojo.MaintenanceWorker;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface MaintenanceWorkerManagementMapper {

    //查询维修员信息
    List<MaintenanceWorker> listMaintenanceWorker(@Param("name") String name, @Param("phone") String phone);

    //添加维修员信息
    @Insert("INSERT INTO dormitorymanagement.maintenanceworker(name, username, password, gender, phone, email, availability_status)"+
            "VALUES (#{name}, #{username}, #{password}, #{gender}, #{phone}, #{email}, #{availabilityStatus})")
    void addMaintenanceWorker(MaintenanceWorker maintenanceWorker);

    //删除维修员信息
    void deleteMaintenanceWorker(@Param("ids") List<Integer> ids);

    //更新维修员信息
    void updateMaintenanceWorker(MaintenanceWorker maintenanceWorker);

    //根据id查询维修员
    @Select("SELECT * FROM dormitorymanagement.maintenanceworker WHERE worker_id = #{id}")
    MaintenanceWorker getMaintenanceWorkerById(int id);

    @Select("SELECT COUNT(*) FROM dormitorymanagement.maintenanceworker WHERE name = #{name}")
    int countByName(String name);

    @Select("SELECT COUNT(*) FROM dormitorymanagement.maintenanceworker WHERE username = #{username}")
    int countByUsername(String username);

    @Select("SELECT COUNT(*) FROM dormitorymanagement.maintenanceworker WHERE phone = #{phone}")
    int countByPhone(String phone);
}
